package com.yesep.learn.netty.protocol.common;

/**
 * @Description: 请求命令返回表
 */
public enum QN_RTN {

	READY(1, "准备执行请求", ""), REFUSE(2, "请求被拒绝", ""), PW_ERROR(3, "密码（PW）错误", ""), MN_ERROR(4, "站点编号（MN）错误", ""), ST_ERROR(5, "系统编号（ST）错误", ""), FLAG_ERROR(6, "应答标志（Flag）错误", ""), QN_ERROR(7, "请求编码（QN）错误", ""), CN_ERROR(8, "命令编码（CN）错误", ""), CRC_ERROR(9, "CRC校验错误", ""), BUSY(10, "系统繁忙不能执行",
			""), PNUM_ERROR(96, "数据包序号错误", ""), DATA_LENGTH_ERROR(97, "数据段长度错误", ""), MSG_ERROR(98, "报文格式错误", ""), NORMAL(99, "正常", ""), UNKNOW(100, "未知错误", "");

	private Integer code;//编号
	private String message;//描述
	private String remark;//备注

	private QN_RTN(Integer code, String message, String remark) {
		this.code = code;
		this.message = message;
		this.remark = remark;
	}

	public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	public String getRemark() {
		return remark;
	}

	@Override
	public String toString() {
		return this.name() + "(" + this.code + " | " + this.message + " | " + this.remark + ")";
	}

	public static QN_RTN get(int code) {
		for (QN_RTN e : QN_RTN.values()) {
			if (e.getCode() == code) {
				return e;
			}
		}
		return null;
	}
}
